package com.tanhua.appserver.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tanhua.model.domain.UserInfo;
import com.tanhua.model.vo.PageResult;
import com.tanhua.appserver.hanlder.UserHolder;
import com.tanhua.dubbointerface.api.BlackListApi;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
public class BlackListService {
    @DubboReference
    private BlackListApi blackListApi;


    public PageResult page(int page, int pagesize) {
        //1、获取当前用户的id
        Long userId = UserHolder.getUserId();
        //2、调用API查询用户的黑名单分页列表  Ipage对象
        IPage<UserInfo> iPage = blackListApi.getPage(userId,page,pagesize);
        //3、对象转化，将查询的Ipage对象的内容封装到PageResult中
        PageResult pr = new PageResult(page,pagesize,iPage.getTotal(),iPage.getRecords());
        //4、返回
        return pr;
    }
}
